I have 4 strings that I would like to separate them with ECMAScript 5 and create a new object with each first element together.
Exemple: Each first element of the array stay in a new variable containing the first element of the first element of the second array and the first element of the last array. Of course I had to separate {PANTONE...} from yellow (they are in the same array) and I create a new array and pushed the color "yellow to it". After I separate the firsts with the seconds, etc, I map them into a new variable
I did with modern JS but I have no clue howe can I do it with "old" JS:
var name = ["{PANTONE Yellow C} {PANTONE 364 C} {PANTONE 137 U} magenta black {PANTONE Reflex Blue C} cyan"]
var percentage = ["0.546829 6.88961 1.03087 0.135706 10.2713 1.98788 0.508267 17.6122"]
var surface = ["1033.87 13025.6 1948.99 256.568 19419 3758.33 960.938 33297.9"]
I want to map it like this:
var result =
{{PANTONE Yellow C}, yellow, 0.546829, 1033.87},
{{PANTONE 364 C}, "no color", 6.88961,6.88961},
{{PANTONE 137 U}, magenta, 1.03087, 1948.99}
you have to use explode the string by space, in more complex situation you should use regular expression for string to array conversion. first of all you have to convert strings into array and then you can create object of that data or you can print as you want.
let str = "0.546829 6.88961 1.03087 0.135706 10.2713 1.98788 0.508267 17.6122";
const arrayExploded = str.split(" ");
arrayExploded[0] //will get 0.546829
now you can use map or any loop function to get all the array data